<?php

/**
 * default actions.
 *
 * @package    sf_sandbox
 * @subpackage default
 * @author     alexey.shapran@gmail.com
 * @version    SVN: $Id: actions.class.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
 */
class defaultActions extends sfActions
{
	public function preExecute()
	{
		if( $this->getUser()->hasAttribute('s_page') )
			$this->getUser()->getAttributeHolder()->remove('s_page');
	}
	/**
	 * Executes index action
	 *
	 * @param sfRequest $request A request object
	 */
	public function executeIndex(sfWebRequest $request)
	{
		//$this->articles = Article::getLastArticles();		
	}

	public function executeError404(sfWebRequest $request)
	{
		if ( $this->getUser()->hasAttribute('category') ) {
			$this->getUser()->getAttributeHolder()->remove('category');
		}
		return sfView::SUCCESS;
	}

	public function executePage(sfWebRequest $request)
	{
		$alias = $this->getRequestParameter('alias');
		$this->Page = Doctrine::getTable('Page')->findOneByAlias($alias);
		$this->forward404Unless($this->Page);
		
		$response = $this->getResponse();
		$response->addMeta('keywords', $this->Page['keywords']);
		$response->addMeta('description', $this->Page['description']);
		$response->setTitle(sfConfig::get('app_title')." | ".$this->Page['title']); 
		
		$this->getUser()->setAttribute('s_page',$this->Page['alias']);
	}
}